#ifndef INCLUDED_IMAGE_H
#define INCLUDED_IMAGE_H
#ifdef __cplusplus
extern "C" {
#endif

#include <lobi/inttypes.h>

#define IMAGE_TYPE_TGA 1
#define IMAGE_TYPE_PCX 2	/* reserved, not yet implemented */
#define IMAGE_TYPE_DDS 3	/* reserved, not yet implemented */
#define IMAGE_TYPE_PNG 4	/* reserved, not yet implemented */
#define IMAGE_TYPE_JPG 5	/* reserved, not yet implemented */

struct image_t
{
	int width, height;
	int num_mipmaps;					// 0 == no mipmaps, must always be 0 :P
	int bytes_per_pixel;				// 1=8bpp(grayscale), 3=24bpp, 4=32bpp
	int num_channels;					// 1=grayscale, 3=rgb, 4=rgba
	/* so, bytes_per_channel = bytes_per_pixel / num_channels */
	char* pixels; // the actual data
};

/* user must alloc the struct, but the memory allocated by the read function must be freed
 * by the image_free() function. dont forget to call image_init() before
 * using image_sread (repeatedly) */

void image_init(struct image_t* image);
void image_free(struct image_t* image);

int image_sread(const char* data,unsigned len, int type, struct image_t* destination_image);

#ifdef __cplusplus
}
#endif
#endif /* INCLUDED_IMAGE_H */
